
import os
pro=os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
路径={
    "前端":os.path.join(pro,"_web","vue_template_store"),
    "后端":os.path.join(pro,"_server","flow_dir")
}
print(路径)
def set_img(obj):
    读取图片所在文件夹=obj["读取图片所在文件夹"]
    保存到=路径[obj["保存到"]]
    for png_name in os.listdir(读取图片所在文件夹):
        # png_name="a_1_1_1_1.png"  =>    a1/a1/a1/a1
        try:
            file_path=os.sep.join(["a"+item for item in png_name.split(".")[0].split("_")[1:]])
            读取路径=读取图片所在文件夹+os.sep+png_name
            保存路径=os.path.join(保存到,file_path,"main.png")
            with open(读取路径,'rb')as f:
                with open(保存路径,"wb")as f2:
                    f2.write(f.read())
            print(读取路径,"=>",保存路径)
        except Exception as e:
            print("error:",png_name,e)

if __name__=="__main__":
    set_img(
        {
            "读取图片所在文件夹":r'C:\Users\Administrator\Desktop\icon_q5rtgcf8sdp',
            "保存到":"前端",
        }
    )